package com.work.dao;

import com.work.pojo.User;
import com.work.utils.DBUtil;
import com.work.utils.MD5utils;

/**
 * @ClassName: UserDaoImpl
 * @Description: TODO
 * @author: meyolo
 * @date: 2021/3/19  12:11
 */
public class UserDaoImpl extends DBUtil implements UserDao {
    @Override
    public int register(User user) {
        String sql = "insert into user value(default,?,?,?,?)";
        return super.executeUpdate(sql,user.getUser_name(),user.getUser_password(),user.getName(),user.getAge());
    }

    @Override
    public User login(String user_name, String user_password) {
        String sql = "select * from user where user_name = ? and user_password = ?";
        return super.executeQueryOne(sql, User.class,user_name, MD5utils.code(user_password));
    }
}
